/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.raitcon.hibernate.backbean;

import com.raitcon.hibernate.bean.Ciclo;
import com.raitcon.hibernate.db.CicloDB;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import javax.annotation.PostConstruct;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
import javax.faces.model.SelectItem;
import org.apache.log4j.Logger;

/**
 *
 * @author Mike
 */
@ManagedBean(name="cicloBean")
@RequestScoped
public class CicloBean implements  Serializable {
    
    
   protected static Logger log = Logger.getLogger(CicloBean.class); 
   private static  final  long serialVersionUID=-2377612760546575078L;
   private String currentItem = "";
   private List<SelectItem> cicloList = new ArrayList<SelectItem>();
   private String selectedCiclo = "0";
   
   @PostConstruct
   protected void init(){
       log.debug("init... CicloBean");
       CicloDB paisDB=new CicloDB();
        List<Ciclo> cicloLst=paisDB.getCicloAll();
        SelectItem item = new SelectItem("0", "--Selecciona Ciclo--");
        getCicloList().add(item);
        for(Ciclo c:cicloLst){
            item = new SelectItem(c.getIdCiclo(), c.getDescripcion());
             getCicloList().add(item);
        }
      
   }

    /**
     * @return the selectedCiclo
     */
    public String getSelectedCiclo() {
        return selectedCiclo;
    }

    /**
     * @param selectedCiclo the selectedCiclo to set
     */
    public void setSelectedCiclo(String selectedCiclo) {
        this.selectedCiclo = selectedCiclo;
    }

    /**
     * @return the cicloList
     */
    public List<SelectItem> getCicloList() {
        return cicloList;
    }

    /**
     * @param cicloList the cicloList to set
     */
    public void setCicloList(List<SelectItem> cicloList) {
        this.cicloList = cicloList;
    }
    
}
